﻿@using Volo.Abp.UI.Navigation
@{
    var elementId = MenuItem.ElementId ?? "MenuItem_" + MenuItem.Name.Replace(".", "_");
    var cssClass = string.IsNullOrEmpty(MenuItem.CssClass) ? string.Empty : MenuItem.CssClass;
    var disabled = MenuItem.IsDisabled ? "disabled" : string.Empty;
    var url = string.IsNullOrEmpty(MenuItem.Url) ? "#" : MenuItem.Url;
}
@if (MenuItem.IsLeaf)
{
    if (MenuItem.Url != null)
    {
        <a class="dropdown-item @cssClass @disabled" href="@url" id="@elementId">
            @if (MenuItem.Icon != null)
            {
                if (MenuItem.Icon.StartsWith("fa"))
                {
                    <i class="@MenuItem.Icon"></i>
                }
            }
            @MenuItem.DisplayName
        </a>
    }
}
else
{
    <div class="dropdown-submenu">
        <a role="button" @onclick="ToggleSubMenu" class="btn dropdown-toggle" data-toggle="dropdown"
                aria-haspopup="true" aria-expanded="false">
            <span class="lp-icon">
                <i class="@(MenuItem.Icon ?? "")"></i>
            </span>
            <span class="lp-text">
                @MenuItem.DisplayName
            </span>
        </a>
        <div class="dropdown-menu border-0 shadow-sm @(IsSubMenuOpen ? "show" : "")">
            @foreach (var childMenuItem in MenuItem.Items)
            {
                <SecondLevelNavMenuItem MenuItem="@childMenuItem"/>
            }
        </div>
    </div>
}
@code {
}
